﻿// 14. Write methods to calculate minimum, maximum, average, sum and product of given set of integer numbers. Use variable number of arguments.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class VariableNumberOfArguments
{
    static void Main()
    {
        int sum = SumCalculation(2, 4, 7, 4, 1, -7, -5, 3);
        Console.WriteLine("The sum of the sequence is: {0}", sum);
        int max = MaxCalculation(2, 4, 7, 4, 1, -7, -5, 3);
        Console.WriteLine("The maximum of the sequence is: {0}", max);
        int min = MinCalculation(2, 4, 7, 4, 1, -7, -5, 3);
        Console.WriteLine("The sum of the sequence is: {0}", min);
        double avarge = AvarageCalculation(2, 4, 7, 4, 1, -7, -5, 3);
        Console.WriteLine("The avarage of the sequence is: {0}", avarge);
        decimal product = ProductCalculation(2, 4, 7, 4, -1, -7, -5, 3);
        Console.WriteLine("The product of the sequence is: {0}", product);
    }

    static int SumCalculation(params int[] sequence)
    {
        int sum = 0;
        foreach (var e in sequence)
        {
            sum += e;
        }
        return sum;
    }

    static int MaxCalculation(params int[] sequence)
    {
        int max = int.MinValue;
        for (int i = 0; i < sequence.Length; i++)
        {
            if (sequence[i] > max)
            {
                max = sequence[i];
            }
        }
        return max;
    }

    static int MinCalculation(params int[] sequence)
    {
        int min = int.MaxValue;
        for (int i = 0; i < sequence.Length; i++)
        {
            if (sequence[i] < min)
            {
                min = sequence[i];
            }
        }
        return min;
    }

    static double AvarageCalculation(params double[] sequence)
    {
        double sum = 0.0;
        foreach (var e in sequence)
        {
            sum += e;
        }
        return sum / sequence.Length;
    }

    static decimal ProductCalculation(params decimal[] sequence)
    {
        decimal product = 1;
        foreach (var e in sequence)
        {
            product *= e;
        }
        return product;
    }
}
